package com.sky.com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageDTO;
import com.sky.entity.Setmeal;
import com.sky.vo.SetmealVO;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SetmealMapper {

    @Select("select count(*) from setmeal where status =#{status}")
    Integer countbYStatus(Integer status);

    @Update("update setmeal set status = #{status} where id in (\n" +
            " select setmeal_id from setmeal_dish where dish_id =#{dishId}\n" +
            ")")
    void updateStatusByDishId(Integer status, Long dishId);

    @AutoFill
    void insert(Setmeal setmeal);



    List<SetmealVO> list(SetmealPageDTO dto);

    // 根据id查询套餐
    @Select("select * from setmeal where id = #{id}")
    Setmeal getById(Long id);

    @AutoFill("update")
    void update(Setmeal setmeal);

    @Delete("delete from setmeal where id = #{setmealId}")
    void delete(Long setmealId);



    List<Setmeal> paramList(SetmealDTO setmealDTO);

    // 根据分类id统计套餐数量
    @Select("select count(*) from setmeal where category_id=#{categoryId}")
    Integer countByCategoryId(Long categoryId);


    // 查询list（条件）
    List<SetmealVO> getList(SetmealPageDTO setmealPageDTO);

    // 根据id删除套餐
    @Delete("delete from setmeal where id = #{id}")
    void deleteById(Long setmealId);



    @AutoFill("update")
    void updateById(Setmeal setmeal);
}
